<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>

<!--  JQuery  -->
<script type="text/javascript" src="../jquery/jquery-1.7.2.min.js"></script>
<script type="text/javascript"
	src="../jquery/jquery-ui-1.8.20.custom.min.js"></script>
<link type="text/css"
	href="../jquery/smoothness/jquery-ui-1.10.1.custom.css"
	rel="stylesheet" />
<link type="text/css"
	href="../jquery/smoothness/jquery-ui-1.10.1.custom.min.css"
	rel="stylesheet" />


<!-- Bootstrap -->
<link href="../twbootstrap/css/bootstrap.min.css" rel="stylesheet"
	media="screen">
<link href="../twbootstrap/css/bootstrap-responsive.min.css"
	rel="stylesheet" media="screen">
<script src="../twbootstrap/js/bootstrap.min.js"></script>
<script src="../twbootstrap/js/bootstrap-dropdown.js"></script>



<!-- js Tree View -->
<script type="text/javascript" src="../jstree/_lib/jquery.js"></script>
<script type="text/javascript" src="../jstree/_lib/jquery.cookie.js"></script>
<script type="text/javascript" src="../jstree/_lib/jquery.hotkeys.js"></script>
<script type="text/javascript" src="../jstree/jquery.jstree.js"></script>
<link type="text/css" rel="stylesheet"
	href="../jstree/_docs/syntax/!style.css" />
<link type="text/css" rel="stylesheet" href="../jstree/_docs/!style.css" />
<script type="text/javascript" src="../_docs/syntax/!script.js"></script>


<script type="text/javascript">
	var data1 = null;

	$(document).ready(function() {
		$("#getdata").click(function() {
			$.ajax({
				type : "post",
				url : "../GetTreeData",
				datatype : "json",
				success : function(data) {
					alert("Data: " + data);
					if (data.length > 0) {
						data1 = data;
					} else {
						Alert("Error getting tree data");
					}
				},
				error : function(jqXHR, textStatus) {
					alert("Request failed: " + textStatus);
				}
			});
		});
	});

	data = [ {
		"data" : "Basics",
		"state" : "closed",
		"children" : [ {
			"data" : "login",
			"state" : "closed",
			"children" : [ "login", {
				"data" : "results",
				"state" : "closed",
				"attr" : {
					"id" : "node-123"
				}
			} ]
		},

		{
			"data" : "Basics",
			"state" : "closed",
			"children" : [ "login", "something", {
				"data" : "results",
				"state" : "closed",
				"attr" : {
					"id" : "node-456"
				}
			} ]
		} ]
	}, {
		"data" : "All",
		"state" : "closed",
		"children" : [ {
			"data" : "AddCustomer",
			"state" : "closed",
			"children" : [ "login", "Add", {
				"data" : "results",
				"state" : "closed",
				"attr" : {
					"id" : "node-789"
				}
			} ]
		} ]
	} ]

	$(function() {
		$("#jstree").jstree(
				{
					"json_data" : {
						"data" : data,
						"ajax" : {
							"url" : "/echo/json/",
							"data" : function(n) {
								// get parent / grandparent node
								var lists = $(n).parents('ul');
								var p = $(lists[0]).prev('a');
								var gp = $(lists[1]).prev('a');
								// the result is fed to the AJAX request 'data' option
								return {
									"parent" : $.trim(p.text()),
									"grandparent" : $.trim(gp.text()),
									"id" : n.attr ? n.attr("id").replace(
											"node-", "") : 1,

								};
							}
						}
					},
					"plugins" : [ "themes", "json_data" ]
				});
	});
</script>
</head>

<body>



	<form id="myForm" action="search.jsp" method="get"
		onsubmit="mySubmit()">


		<input type="hidden" id="searchstr" name='searchstr' value='' />


		<script>
			function mySubmit() {
				// alert("Data: "+ $("#searchparam").val());
				document.getElementById('searchstr').value = $("#searchparam")
						.val();
				document.getElementById("myForm").submit();
			}
		</script>



		<div class="navbar navbar-static-top">
			<div class="navbar-inner">
				<a class="brand" href="../wiki/home.jsp">Issue Tracker</a>
				<ul class="nav">
					<li class="divider-vertical"></li>
					<li id="addissue"><a href="../wiki/addIssue.jsp">Add Issue</a></li>
					<li class="divider-vertical"></li>
					<li id="allissue"><a href="../wiki/allIssues.jsp">Issues</a></li>
					<li class="divider-vertical"></li>
					<li class="span2"></li>
					<div class="form-search nav pull-right">
						<li class="input-append" style="margin-top: 5px;"><input
							id="searchparam" type="text" class="span4 search-query">
							<button type="submit" class="btn">Search</button></li>
					</div>

				</ul>

				<ul class="nav pull-right">
					<li class="divider-vertical"></li>
					<li class="dropdown"><a href="#" class="dropdown-toggle"
						data-toggle="dropdown">Admin <b class="caret"></b></a>
						<ul class="dropdown-menu">
							<li><a href="settings.jsp">Modules</a></li>
							<li><a href="userroles.jsp">Permissions</a></li>
							<li><a href="reports.jsp">Reports</a></li>
						</ul></li>
					<li class="divider-vertical"></li>
					<li class="dropdown"><a href="#" class="dropdown-toggle"
						data-toggle="dropdown">Welcome <%=(String) session.getAttribute("firstname")%>
							<b class="caret"></b></a>
						<ul class="dropdown-menu">
							<li><a href="SendFeedback.jsp">Send Feedback</a></li>
							<li><a href="Logout.jsp">Logout</a></li>
						</ul></li>
				</ul>
			</div>
		</div>
	</form>

	<h2>
		Issue &nbsp;&nbsp; <input type="button" id="getdata" class="btn"
			value="read">
	</h2>

	<div id="jstree"></div>
</body>

</html>